How to add confirm email address field in WooCommerce checkout page? 您所在的位置:网站首页 confirm email address How to add confirm email address field in WooCommerce checkout page?

How to add confirm email address field in WooCommerce checkout page?

#How to add confirm email address field in WooCommerce checkout page?| 来源: 网络整理| 查看: 265

In some situations default WooCommerce email validation is not good enough. If your clients often enter the wrong email address on the checkout page, you can try adding confirm email address field in the WooCommerce checkout page. In this article, I’ll show you how to do this with the free plugin.

The purchasing process is a very complex and fragile element for every eCommerce. Imagine all your hard work is destroyed by a trivial mistake like misspelled email address on the checkout page. In the best scenario, you will have to spend some time answering your client. In the worst one, your client will be annoyed. Even it’s not your fault you will lose time or money.

Read our guide about default Email Validation for Custom Fields. Custom checkout fields

There is a simple solution for that, and it possible to achieve with our free plugin! It’s Flexible Checkout Fields, and people love it. We have received a lot of positive feedback from users. Also, over 70,000 stores worldwide use this plugin on a daily basis!

Flexible Checkout Fields allows you to:

change fields' names, change the order of fields, create new, custom fields, add validation to fields, change fields' look.

Yes, it’s all for free!

Flexible Checkout Fields WooCommerce

Edit, add new or hide unnecessary fields from the checkout form. It's all about conversions and better user experience.

Download for free or Go to WordPress.org WP Desk 70,000+ Active Installations Last Updated: 2022-06-20 Works with WooCommerce 6.3 - 6.6.x How to add confirm email address field in WooCommerce checkout?

If you have the plugin installed and activated, you can go to WooCommerce > Checkout Fields.

WooCommerce checkout fields

In the billing section, add a new Single Line Field. Add a label and click on Add Field button.

Add new checkout field

Next, put the new field below your email address field. You can do this with simple drag and drop.

drag and drop the checkout fields

Set this field as Required.

Required custom checkout field

With this setup, two email address fields will be displayed one below the other. 

Two checkout fields

If you want to display them side by side, you can do this with CSS classes. Just add a special class in the Appearance section. 

In the first field, set it as form-row-first.

First confirm email address field

In the second, form-row-last.

Second confirm email address checkout field

With this CSS classes, both fields will be displayed side by side. 

Two checkout fields side by side

Add custom validation to the field

If you have your fields, now it’s time to add custom validation. We have special documentation about it, where you will find more useful validations. But for adding confirm email address field in WooCommerce checkout, we will use this code.

Just add this to your functions.php file. Next, go back to your checkout fields page, and refresh it. Now, you should be able to choose Compare with billing_email in the validation field. When you do that, save the changes.

custom email address validation

Confirm email address field in WooCommerce checkout

Let’s find out how it will work on the checkout page. Two email address fields aren’t filled exactly the same.

confirm email address field in WooCommerce checkout

When I try to place an order, I get an error message.

error message on the checkout page

You can change the default error message, by editing this code.

wc_add_notice( sprintf( __( 'Invalid %1$s value.', 'wpdesk' )

To do that, just change 'Invalid %1$s value.'.

Confirm other checkout fields

You can check other field in the similar way. Just edit the following code: $fcf_validation_confirm_field = new WPDesk_FCF_Validation_Confirm_Field( 'billing_email' );

Change billing_email for other fields, like billing_my_custom_field.

Summary

In this article I showed you how to add confirm email address field in the WooCommerce checkout page. This will allow you to limit your clients’ error, and secure your purchasing process. I hope it will be useful for you. Good luck!

Tweet


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

      专题文章
        CopyRight 2018-2019 实验室设备网 版权所有